﻿using IBLL;
using IDAL;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL
{
    public class MemberBLL : IMemberBLL
    {
        public MemberBLL(IBaseDAL<Member> dAL)
        {
            DAL = dAL;
        }

        public IBaseDAL<Member> DAL { get; }

        public Member Login(string name, string pwd)
        {
            var query = DAL.GetAll();
            var m = query.FirstOrDefault(x => x.Name == name); //null和正确的对象
            if (m == null) {
                m = new Member { Id = -1 };
            }
            else
            {
                if (m.Password != pwd) {
                    m = new Member { Id = -2 };
                }
            }
            return m;
        }
    }
}
